package cn.tedu.innerclass.work19;

public class Work {
    public static void main(String[] args) {
        Thread t1=new Thread(){
            public void run()
            {
                synchronized (this){
                    System.out.println(Thread.currentThread().getName() + "开始执行...");
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        Thread t2=new Thread(){
            public void run(){
                synchronized (this) {
                    System.out.println(Thread.currentThread().getName() + "开始执行...");
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + "执行完毕.");
                }
            }
        };

        t1.start();
        t2.start();

    }
}
